import { BasicColumn } from '/@/components/Table/src/types/table';
import { FormSchema } from '/@/components/Table';
import dayjs from 'dayjs';

export function getBasicColumns(): BasicColumn[] {
  return [
    {
      title: '终端类型',
      dataIndex: 'a0',
      width: 80,
      customRender({}) {
        return 'app';
      },
    },
    {
      title: '预订时间',
      dataIndex: 'a1',
      width: 170,
      customRender({ record }) {
        return dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss');
      },
    },
    {
      title: '预订人',
      dataIndex: 'a2',
      width: 80,
      customRender({ record }) {
        return record.reserveName;
      },
    },
    {
      title: '出差申请单号',
      dataIndex: 'a3',
      width: 180,
      customRender({ record }) {
        return record.externalApprovalNo ? record.externalApprovalNo : '-';
      },
    },
    {
      title: '订单号',
      dataIndex: 'a4',
      width: 190,
      customRender({ record }) {
        return record.orderNo;
      },
    },
    {
      title: '职工编号',
      dataIndex: 'a5',
      width: 80,
      customRender({ record }) {
        return record.accountNo;
      },
    },
    {
      title: '乘车人',
      dataIndex: 'a6',
      width: 80,
      customRender({ record }) {
        return record.orderDetailDto.passengerList[0].name;
      },
    },
    {
      title: '乘车人电话',
      dataIndex: 'a7',
      width: 120,
      customRender({ record }) {
        return record.orderDetailDto.passengerList[0].phone;
      },
    },
    {
      title: '上车地点',
      dataIndex: 'a8',
      width: 200,
      customRender({ record }) {
        return record.departCityName + '-' + record.departAddress;
      },
    },
    {
      title: '下车地点',
      dataIndex: 'a9',
      width: 200,
      customRender({ record }) {
        return record.arriveCityName + '-' + record.arriveAddress;
      },
    },
    {
      title: '用车时间',
      dataIndex: 'a10',
      width: 170,
      customRender({ record }) {
        return record.departureTime
          ? dayjs(record.departureTime).format('YYYY-MM-DD HH:mm:ss')
          : '-';
      },
    },
    {
      title: '抵达时间',
      dataIndex: 'a70',
      width: 180,
      customRender({ record }) {
        return record.finishTime ? dayjs(record.finishTime).format('YYYY-MM-DD HH:mm:ss') : '-';
      },
    },
    {
      title: '车型等级',
      dataIndex: 'a11',
      width: 90,
      customRender({ record }) {
        if (record.carCategory === 'COMFORT') return '舒适型';
        if (record.carCategory === 'ECONOMIC') return '经济型';
      },
    },
    {
      title: '供应商渠道',
      dataIndex: 'a12',
      width: 100,
      customRender({ record }) {
        return record.orderDetailDto.childChannelName
          ? record.orderDetailDto.childChannelName
          : '-';
      },
    },
    {
      title: '出差人数',
      dataIndex: 'a13',
      width: 80,
      customRender({ record }) {
        return record.orderDetailDto.passengerList.length;
      },
    },
    {
      title: '车费',
      dataIndex: 'a14',
      width: 80,
      customRender({ record }) {
        return record.realFee;
      },
    },
    {
      title: '深白云服务费',
      dataIndex: 'a15',
      width: 80,
      customRender({}) {
        return 0;
      },
    },
    {
      title: '售票处服务费',
      dataIndex: 'a16',
      width: 80,
      customRender({}) {
        return 0;
      },
    },
    {
      title: '深白云扣款',
      dataIndex: 'a17',
      width: 80,
      customRender({ record }) {
        return record.realFee;
      },
    },
    {
      title: '应收总计',
      dataIndex: 'a18',
      width: 80,
      customRender({ record }) {
        return record.realFee;
      },
    },
    {
      title: '总金额包含服务费',
      dataIndex: 'a19',
      width: 80,
      customRender({ record }) {
        return record.realFee;
      },
    },
    {
      title: '车辆信息',
      dataIndex: 'a20',
      width: 180,
      customRender({ record }) {
        return record.orderDetailDto.driver ? record.orderDetailDto.driver.licensePlate : '-';
      },
    },
    {
      title: '订单类型',
      dataIndex: 'a21',
      width: 80,
      customRender({}) {
        return '有审批单';
      },
    },
    {
      title: '服务商编码',
      dataIndex: 'a22',
      width: 100,
      customRender({ record }) {
        return record.orderDetailDto.proxyId;
      },
    },
    {
      title: '客户名称',
      dataIndex: 'a23',
      width: 80,
      customRender({ record }) {
        return record.orderDetailDto.passengerList[0].name;
      },
    },
    {
      title: '客户编号',
      dataIndex: 'a24',
      width: 80,
      customRender({ record }) {
        return record.accountNo;
      },
    },
    {
      title: '收款状态',
      dataIndex: 'a25',
      width: 80,
      customRender({ record }) {
        return record.payStatus === 'UNPAID' ? '未支付' : '已支付';
      },
    },
    {
      title: '结算状态',
      dataIndex: 'a26',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '联系人',
      dataIndex: 'a27',
      width: 80,
      customRender({ record }) {
        return record.reserveName;
      },
    },
    {
      title: '联系人电话',
      dataIndex: 'a28',
      width: 120,
      customRender({ record }) {
        return record.orderDetailDto.passengerList[0].phone;
      },
    },
    {
      title: '成本中心',
      dataIndex: 'a29',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: 'OA申请单号',
      dataIndex: 'a30',
      width: 160,
      customRender({ record }) {
        return record.externalApprovalNo ? record.externalApprovalNo : '-';
      },
    },
    {
      title: '业务经理',
      dataIndex: 'a31',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '服务商名称',
      dataIndex: 'a32',
      width: 100,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '服务费',
      dataIndex: 'a33',
      width: 80,
      customRender({}) {
        return 0;
      },
    },
    {
      title: '供应商单号',
      dataIndex: 'a34',
      width: 100,
      customRender({ record }) {
        return record.orderDetailDto.channelOrderNo;
      },
    },
    {
      title: '订单来源',
      dataIndex: 'a35',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '预订人部门',
      dataIndex: 'a36',
      width: 100,
      customRender({ record }) {
        return record.examineApprove ? record.examineApprove.departmentId : '-';
      },
    },
    {
      title: '支付状态',
      dataIndex: 'a37',
      width: 80,
      customRender({}) {
        return '已支付';
      },
    },
    {
      title: '支付方式',
      dataIndex: 'a38',
      width: 80,
      customRender({}) {
        return '月结';
      },
    },
    {
      title: '个人支付金额',
      dataIndex: 'a39',
      width: 120,
      customRender({}) {
        return '0';
      },
    },
    {
      title: '个人退款金额',
      dataIndex: 'a40',
      width: 120,
      customRender({}) {
        return '0';
      },
    },
    {
      title: '公司支付金额',
      dataIndex: 'a41',
      width: 120,
      customRender({ record }) {
        return record.realFee ? record.realFee : 0;
      },
    },
    {
      title: '公司退款金额',
      dataIndex: 'a42',
      width: 120,
      customRender({}) {
        return '0';
      },
    },
    {
      title: '交易流水号',
      dataIndex: 'a43',
      width: 100,
      customRender({}) {
        return '0';
      },
    },
    {
      title: '费用承担部门',
      dataIndex: 'a44',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '项目编号',
      dataIndex: 'a45',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '项目名称',
      dataIndex: 'a46',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '差旅事项',
      dataIndex: 'a47',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '超标原因',
      dataIndex: 'a48',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '超标金额',
      dataIndex: 'a49',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '超标描述',
      dataIndex: 'a50',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '费用类型',
      dataIndex: 'a51',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '差旅授权号',
      dataIndex: 'a52',
      width: 100,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批状态',
      dataIndex: 'a53',
      width: 80,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '给审批人留言',
      dataIndex: 'a54',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组1类型',
      dataIndex: 'a55',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组1审批人',
      dataIndex: 'a56',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组2类型',
      dataIndex: 'a57',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组2审批人',
      dataIndex: 'a58',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组3类型',
      dataIndex: 'a59',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组3审批人',
      dataIndex: 'a60',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组4类型',
      dataIndex: 'a61',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '审批组4审批人',
      dataIndex: 'a62',
      width: 120,
      customRender({}) {
        return '-';
      },
    },
    {
      title: '员工部门',
      dataIndex: 'a63',
      width: 80,
      customRender({ record }) {
        return record.examineApprove ? record.examineApprove.departmentId : '-';
      },
    },
    {
      title: '消费记录id（唯一值）',
      dataIndex: 'a64',
      width: 100,
      customRender({ record }) {
        return record.id;
      },
    },
    // {
    //   title: '订单号',
    //   dataIndex: 'a65',
    //   width: 200,
    //   customRender({ record }) {
    //     return record.orderNo;
    //   },
    // },
    // {
    //   title: '出发时间',
    //   dataIndex: 'a66',
    //   width: 180,
    //   customRender({ record }) {
    //     return record.departureTime
    //       ? dayjs(record.departureTime).format('YYYY/MM/DD HH:mm:ss')
    //       : '-';
    //   },
    // },
    // {
    //   title: '到达时间',
    //   dataIndex: 'a67',
    //   width: 180,
    //   customRender({ record }) {
    //     return record.finishTime ? dayjs(record.finishTime).format('YYYY/MM/DD HH:mm:ss') : '-';
    //   },
    // },
    {
      title: '乘车人卡号',
      dataIndex: 'a68',
      width: 100,
      customRender({ record }) {
        return record.orderDetailDto.passengerList[0].certNo
          ? record.orderDetailDto.passengerList[0].certNo
          : '-';
      },
    },
  ];
}
export const searchFormSchema: FormSchema[] = [
  {
    field: 'createTime',
    component: 'RangePicker',
    label: '预订日期',
    colProps: {
      span: 6,
    },
    componentProps: {
      placeholder: ['预订日期起', '预订日期止'],
      style: 'width: 220px',
    },
    defaultValue: [getCurrentDataL(), getCurrentDataR()],
  },
  {
    field: 'departTime',
    component: 'RangePicker',
    label: '出发日期',
    colProps: {
      span: 6,
    },
    componentProps: {
      placeholder: ['出发日期起', '出发日期止'],
      style: 'width:220px',
    },
  },
  {
    field: 'finishTime',
    component: 'RangePicker',
    label: '到达日期',
    colProps: {
      span: 6,
    },
    componentProps: {
      placeholder: ['到达日期起', '到达日期止'],
      style: 'width:220px',
    },
  },
  {
    field: 'accountNo',
    label: '职工编号',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: ' ',
      style: 'width: 220px',
    },
  },
  {
    field: 'reserveName',
    label: '职工姓名',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: ' ',
      style: 'width: 220px',
    },
  },
  {
    field: 'orderNo',
    label: '订单编号',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: ' ',
      style: 'width: 220px',
    },
  },
  // {
  //   field: 'accountNoY',
  //   label: '预定人工号',
  //   component: 'Input',
  //   colProps: { span: 6 },
  //   componentProps: {
  //     placeholder: ' ',
  //     style: 'width: 220px',
  //   },
  // },
  {
    field: 'carCategory',
    label: '车型',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      style: 'width: 220px',
      placeholder: '请选车型',
      // style: 'width: 180px',
      options: [
        { label: '舒适型', value: 'COMFORT' },
        { label: '经济型', value: 'ECONOMIC' },
      ],
    },
  },

  // if (record.carCategory === 'COMFORT') return '舒适型';
  //       if (record.carCategory === 'ECONOMIC') return '经济型';
];
//获得当前年份4位年
function getCurrentDataL() {
  return dayjs(dayjs().year().toString() + '-' + Number(dayjs().month()) + '-15').format(
    'YYYY-MM-DD',
  );
}
function getCurrentDataR() {
  // return new Date().toLocaleDateString();
  return dayjs(dayjs().year().toString() + '-' + Number(dayjs().month() + 1) + '-16').format(
    'YYYY-MM-DD',
  );
}
